import { createStore } from "redux";

const listReducer = (state={list:[]}, action) => {
    switch (action.type) {
        case 'add_item':
            return {list: [action.item, ...state.list]};  
        case 'del_item':
            state.list.splice(action.index, 1);
            return {list: [...state.list]};
        default:
            return state;
    }
};

const store = createStore(listReducer);

export default store;